package com.example.wechat_home_page;



import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import java.util.List;

public class MyAdaper extends RecyclerView.Adapter<MyAdaper.MyHolder> {
    private List<RecyBean> data;
    private Context context;

    public MyAdaper(Context context) {
        this.context = context;
    }

    public void setData(List<RecyBean> data) {
        this.data = data;
    }

    @NonNull
    @Override
    public MyHolder onCreateViewHolder(@NonNull  ViewGroup parent, int viewType) {
        return new MyHolder(LayoutInflater.from(context).inflate(R.layout.list_item_layout,null));
    }

    @Override
    public void onBindViewHolder(@NonNull  MyAdaper.MyHolder holder, int position) {
        holder.couname.setText(data.get(position).getRecyname());
        holder.couid.setImageResource(data.get(position).getRecyid());
        holder.time.setText(data.get(position).getTime());
        holder.input.setText(data.get(position).getInput());

    }

    @Override
    public int getItemCount() {
        return null!=data?data.size():0;
    }

    class MyHolder extends RecyclerView.ViewHolder{
        TextView couname;
        ImageView couid;
        TextView time;
        TextView input;

        public MyHolder(@NonNull View itemView) {
            super(itemView);
            couname=itemView.findViewById(R.id.text_name);
            couid=itemView.findViewById(R.id.imag_picter);
            time=itemView.findViewById(R.id.text_time1);
            input=itemView.findViewById(R.id.text_num1);

        }
    }
}
